<!doctype html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>GIERA</title>
	
		<style>
		
			*
			{
				padding:0;
				margin:0;
			}
			
			body
			{
				background-color:#000;
				font-family:Courier;
				-webkit-user-select: none;	       
				-moz-user-select: none;
				-ms-user-select: none;
				cursor:default;
				color:#FFF;
			}
			
			input[type=button]
			{
				margin : 10px;
				background-color:transparent;
				font-size:14px;
				font-weight:bold;
				border: 3px solid #F00;
				color:#FFF;
				padding:7px;
			}
			
			input[type=button]:hover
			{
				background-color:#757575;
			}
			
			div
			{
				background-color:#757575;
				font-size:14px;
				font-weight:bold;
				border: 3px solid #F00;
				min-width:100px;
				min-height:100px;
				color:#000;
			}
			
			#konsola
			{
				position:absolute;
				right:0px;
				bottom:0px;
				width:600px;
				height:150px;
				overflow:hidden;
			}
			
			#canvas
			{
				width:500px;
				height:350px;
				margin: 100px 400px;
				background-color:#666;
				border:1px solid #FFF;
			}
			
			#datadiv
			{
				position:absolute;
				left:0;
				top:0;
				padding:10px;
				background-color:#000;
				color:#666;
			}
			
		</style>
	
		<script src="game.js"></script>
		<script>
			
			document.addEventListener("DOMContentLoaded",function(){
			
				window.currentLVL = 4;
				window.objects = ["grass","wall","box","snow","movable","key","portal","fire","task"];
				window.tipz=["Zuap Ptaqa!",
							"Oto ściany :)",
							"Możesz niszczyć skrzynie!",
							"LooD y'est $lizK!",
							"Przesooway KloCk!:)",
							"PozbieraY Wszystki3 klucze!",
							"Użyj portali do teleportacji!",
							"Unikaj ognia... jak ognia(lol?)",
							"",
							""];
				window.time=0;
				window.canvas = document.getElementById("canvas");
				window.game = new Game(canvas,"lvl/"+ window.currentLVL +".txt",window.tipz[window.currentLVL]);
				
				var files = ["object.js"] ;
				for( i in window.objects )files[files.length] = "objects/"+window.objects[i]+".js";
				
				for( i in files )
				{
					var js = document.createElement("script");
					js.src = files[i];
					document.body.appendChild(js);
				}
				
				
				launchGame();
				//setTimeout("game.listObjects()",10);
			});
			
			function launchGame()
			{
				window.game.end=false;
				window.game.task=window.tipz[window.currentLVL];
				window.game.boardFile="lvl/"+ window.currentLVL +".txt";
				window.game.info = ["GET RDY!"];

				
				window.game.startGame();
				inter = setInterval(timer,100);
			}
			
			function timer()
			{
				if(!window.game.gamePaused)
				{
					window.time++;
					console.log( window.time );
				}
				if( window.game.end )
				{
					var to = 0;
					if( !window.game.playerDead )
					{
						alert("Twój czas to " + time);
						window.currentLVL++;
					}
					else to = 1000;
					clearInterval(inter);
					
					setTimeout(launchGame,to);
				}
			}
			
		</script>
		
	</head>
	<body>
	
		<canvas id="canvas"></canvas>
		
	</body>

</html>